package io.renren.modules.task.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import io.renren.modules.task.dao.MtCcParkingPositionDao;
import io.renren.modules.task.entity.MtCcParkingPositionEntity;
import io.renren.modules.task.service.MtCcParkingPositionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import static io.renren.modules.task.enums.MtCcEnum.ENDPRODUCT_SUCCESS_POSITION;

/**
 * @Author: 蔡翔
 * @Date: 2019/7/3 10:04
 * @Version 1.0
 */
@Service
public class MtCcParkingPositionServiceImpl extends ServiceImpl<MtCcParkingPositionDao, MtCcParkingPositionEntity> implements MtCcParkingPositionService {
    @Autowired
    private MtCcParkingPositionService mtCcParkingPositionService;

    @Override
    public String selectAPerfectPosition() {
        QueryWrapper<MtCcParkingPositionEntity> queryWrapperPP = new QueryWrapper<>();
        String destinationNo = "";
        Map<String,Object> mapPP = new HashMap<>();
        mapPP.put("parking_status",ENDPRODUCT_SUCCESS_POSITION);
        queryWrapperPP.allEq(mapPP);
        List<MtCcParkingPositionEntity> listPP = mtCcParkingPositionService.getBaseMapper().selectList(queryWrapperPP);
        boolean flag = !listPP.isEmpty();
        if(flag){  // 这里会有数组越界问题
            destinationNo = listPP.get(0).getParkingPoint();
        }
        listPP.forEach(System.out::println);
        return destinationNo;
    }
}
